/**
 * Created by Administrator on 16-11-8.
 */

$(function(){
    function stopPropagation(e) {
        e = e || window.event;
        if(e.stopPropagation) { //W3C阻止冒泡方法
            e.stopPropagation();
        } else {
            e.cancelBubble = true; //IE阻止冒泡方法
        }
    }
    //聊天表情
    var chatFace2=['0.gif','1.gif','2.gif','3.gif','4.gif','5.gif','6.gif','7.gif','8.gif','9.gif',
        '10.gif','11.gif','12.gif','13.gif','14.gif','15.gif','16.gif','17.gif','18.gif','19.gif',
        '20.gif','21.gif','22.gif','23.gif','24.gif','25.gif','26.gif','27.gif','28.gif','29.gif',
        '30.gif','31.gif','32.gif','33.gif','34.gif','35.gif','36.gif','37.gif','38.gif','39.gif',
        '40.gif','41.gif','42.gif','43.gif','44.gif','45.gif','46.gif','47.gif','48.gif','49.gif',
        '50.gif','51.gif','52.gif','53.gif','54.gif','55.gif','56.gif','57.gif','58.gif','59.gif',
        '60.gif','61.gif','62.gif','63.gif','64.gif','65.gif','66.gif','67.gif','68.gif','69.gif',
        '70.gif','71.gif','72.gif','73.gif','74.gif','75.gif','76.gif','77.gif','78.gif','79.gif',
        '80.gif','81.gif','82.gif','83.gif','84.gif','85.gif','86.gif','87.gif','88.gif','89.gif',
        '90.gif','91.gif','92.gif','93.gif','94.gif','95.gif','96.gif','97.gif','98.gif','99.gif',
        '100.gif','101.gif','102.gif','103.gif','104.gif','105.gif','106.gif','107.gif','108.gif','109.gif',
        '110.gif','111.gif','112.gif','113.gif','114.gif','115.gif','116.gif','117.gif','118.gif','119.gif'];
    //聊天表情路劲
//    var chatAddress='/Public/home/image/face/chat-face/';
    var chatAddress='http://icon.jt018.com/zb/v1/face/chat-face/';

    var oFaceBtn2=document.getElementById('faceBtn2');
    var oFaceCentent2=document.getElementById('faceCentent2');
    var oChatText2=document.getElementById('chatText2');
    oFaceBtn2.onclick=function(e)
    {
        if(oFaceCentent2.style.display=='none')
        {
            for(var i=0;i<chatFace2.length;i++)
            {
                var aEm=document.createElement('em');
                var aImg=document.createElement('img');
                aImg.src=chatAddress+chatFace2[i];
                aEm.appendChild(aImg);
                oFaceCentent2.appendChild(aEm);
            }

            var oFaceBtn2=oFaceCentent2.getElementsByTagName('em');
            oFaceCentent2.style.display='block';
            console.log('oFaceBtn2 长度:');
            console.log(oFaceBtn2.length);
            for(var j=0;j<oFaceBtn2.length;j++)
            {
                oFaceBtn2[j].onclick=function()
                {
                    var faceSrc='<img src="'+this.children[0].getAttribute('src')+'">';
                    oChatText2.focus();
                    console.log('result');
                    console.log(oChatText2.focus());
                    insertimg('chatText2',faceSrc);
                    oFaceCentent2.style.display='none';
                    oFaceCentent2.innerHTML='';
                }
            }
        }
        else
        {
            oFaceCentent2.style.display='none';
            oFaceCentent2.innerHTML='';
        }

        stopPropagation(e)
    }

});

